<?php 
/***
 * 登录管理控制器
 */
class LoginController extends Controller{
	private $model;
	public function __init(){
		$this->model = K('User');
	}
	/**
	 * 加载页面
	 */
	public function index(){
		if(IS_POST){
			if(!$userInfor = $this->model->login()) $this->error($this->model->error);
			$_SESSION['username'] = $userInfor['username'];
			$_SESSION['uid'] = $userInfor['uid'];
			//修改登录时间
			$data = array(
				'login' => time()
			);
			$this->model->where("uid={$userInfor['uid']}")->update($data);
			//创建session
			$_SESSION['username'] = $userInfor['username'];
			$_SESSION['uid'] = $userInfor['uid'];
			$_SESSION['nick'] = $userInfor['nick'];
			$this->success('登录成功',U('Index/Index/index'));
		}
		
		$this->display();
	}
	
}


















 ?>